package com.zhanglingfei.yuekaoshop.repository;

import com.zhanglingfei.yuekaoshop.entity.Brand;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
@author Shichao.Lu
*/
public interface BrandRepository extends JpaRepository<Brand, Long> {

    List<Brand> findByNameLikeAndLetterOrderByLetter(String name,String letter);

    @Transactional
    @Modifying
    int deleteAllByNameAndLetter(String name,String letter);


    @Query(value = "select * from tb_brand where name like :name",nativeQuery = true)
    List<Brand> getListByName(@Param("name") String name);

}
